package com.huilian.iotbox.mqtt.server.base.handler;

import com.huilian.iotbox.aliyun.service.PubService;
import com.huilian.iotbox.data.cmd.PositiveDataFrameCMD;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * OutwardCoinLevelHandler
 * 24.2、设置向外投币电平（支付盒子to服务器）
 *
 * @Author mineChen
 * @Date 2021/8/28 上午 10:58
 */
@Slf4j
@Service("messageHandleService27")
public class OutwardCoinLevelHandler implements MessageHandlerStrategy {

    @Autowired
    private PubService pubService;

    @Override
    public void process(String content, String deviceNo, String productKey, Integer serviceProviderCode) {
        log.info("进入 设置向外投币电平结果" + deviceNo);

        final String status = content.substring(8, 10);
        if ("00".equals(status)){
            log.error("设置向外投币电平: 失败");
        } else if ("01".equals(status)){
            log.info("设置向外投币电平: 成功");
        }

        String tcp = PositiveDataFrameCMD.boxParamsQuery();
        pubService.pub(tcp, deviceNo, productKey);
    }
}
